package tech.aistar.corejava.day17.reflection;

import tech.aistar.corejava.day11.User;
import tech.aistar.corejava.day17.Gender;

import java.util.Date;

/**
 * @Author: lya
 * @Description: 本类的作用描述:
 * @CreateDate: 2019/8/6
 * @Version: 1.0
 */
public class ClassDemo {
    public static void main(String[] args) {
        //基本类型.class
        System.out.println(int.class);//int

        //包装类型.class
        System.out.println(Integer.class);//class java.lang.Integer

        User u1 = new User(1,"tom", Gender.F,new Date());

        //对象.getClass()
        System.out.println(u1.getClass());

        User u2 = new User(1,"tom", Gender.F,new Date());

        //类名.class
        System.out.println(User.class);

        //结论 - 一个类无论被实例化多少次,它在JVM中的class实例永远只有一个
        System.out.println(u1.getClass() == User.class);//true

        //Class.forName("类型权限定名");

        try {
            Class<?> c = Class.forName("tech.aistar.corejava.day17.User");

            System.out.println(c);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
